home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 14 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.0 KB  |  44 lines

  1. Path: chronicle.mti.sgi.com!news
  2. From: solution@gate.net (Ken Walter)
  3. Newsgroups: comp.std.c++
  4. Subject: Initialization of Static Components of a Template Class
  5. Date: 08 Jan 1996 23:05:11 GMT
  6. Organization: Solution Technology
  7. Approved: austern@mti.sgi.com
  8. Message-ID: <4cr2m1$1kcq@news.gate.net>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
  11.  
  12.  
  13.  
  14. If I have a template class such as:
  15.  
  16. template<class T> SOMEclass
  17. {
  18. ..
  19. private:
  20. static int AStatic;
  21. }
  22.  
  23.  
  24. I would like to also be able to say in the header file:
  25.  
  26. template<class T> int SOMEclass::AStatic(0); 
  27.  
  28. and have it automaticaly expanded by the compiler with the template class.
  29.  
  30. Requiring the users of the template class to initialize ever class instance
  31. is very inconvenient!  It almost forces one to use a macro:
  32.  
  33. #define SOMEclassSTATICS( T )  int SOMEclass<T>::AStatic(0); /
  34.                     // other initialization of SOMEclass statics
  35.  
  36. Or am I missing somrthing from the latest language definition?
  37.  
  38. Ken Walter
  39.  
  40. * All the above is hearsay and the opinion of nobody in particular
  41.  
  42.  
  43.  
  44.